/*接口*/
import request from "./request";
import config from "./config";

/**
 * 检查网络
 */
export function testNetWork(success,fail) {
	var timestamp = Date.parse(new Date())
	  return request({
	    url: 'http://wx.4006002222.com/hnWhMobile/static/checkNetwork.txt?v=' + timestamp,
	    method: 'get',
		responseType: 'text',
	    data: { responseType: 'blob' },
	    timeout: 6000,
		success,
		fail
	  })
}

/**
 * 登录认证
 */
export function qywxWebLogin(data, success, fail) {
  return request({
    url: config.api + "/qywxWebLogin/" + data.lesseeid + "/" + data.code,
    method: "post",
    success,
    fail,
  });
}

/**
 * wxjsdk认证
 */
export function qywxJssdk(data, success, fail) {
  return request({
    url: config.api + "/qywxJssdk",
    method: "post",
    data,
    success,
    fail,
  });
}

/**
 * 获取数据字典
 * /system/dict/data/type/{type}
 */
export function getSystemDictData(type, success, fail) {
  var data = {};
  return request({
    url: config.api + "/system/dict/data/type/" + type,
    method: "get",
    data,
    success,
    fail,
  });
}

/**
 * 查询附件列表
 */
export function getFileList(data, success, fail) {
  return request({
    url: config.api + "/basic/file/list",
    method: "get",
    data,
    success,
    fail,
  });
}

/**
 * 删除附件
 */
export function deleteFile(data, success, fail) {
  return request({
    url: config.api + "/basic/file/" + data.ids,
    method: "delete",
    data,
    success,
    fail,
  });
}

/**
 * 查询附件列表
 */
export function getWeekDayInfo(data, success, fail) {
  return request({
    url: config.api + "/basic/week/dayInfo",
    method: "get",
    data,
    success,
    fail,
  });
}

/**
 * 新增时, 获取预定的记录id
 */
export function getPreId(data, success, fail) {
  return request({
    url: config.api + "/common/getId",
    method: "get",
    data,
    success,
    fail,
  });
}

/**
 * 转店打卡-获取门店考勤点
 */
export function getMapJmSalesDeviceInfo(data, success, fail) {
  return request({
    url: config.api + "/qyxd/xcx/getDeviceInfo",
    method: "get",
    data,
    success,
    fail,
  });
}


/**
 * 巡店-获取附近门店
 */
export function getNearByStores(data, success, fail) {
  return request({
    url: config.api + "/qyxd/xcx/findstore",
    method: "get",
    data,
    success,
    fail,
  });
}

/**
 * 门店打卡
 */
export function dkByMapJmSalesDevice(data, success, fail) {
  return request({
    url: config.api + "/qyxd/xcx/xdclock",
    method: "POST",
    data,
    success,
    fail,
  });
}

/**
 * 查询转店打卡记录
 */
export function getMapJmSalesDkInfo(data, success, fail) {
  return request({
    url: config.api + "/qyxd/xcx/xdclockrecord",
    method: "get",
    data,
    success,
    fail,
  });
}

/**
 * 查询巡店记录
 */
export function getXDInfoList(data, success, fail) {
  return request({
    url: config.api + "/qyxd/xcx/findAnything",
    method: "get",
    data,
    success,
    fail,
  });
}

/**
 * 查询根据经纬度查附近的门店
 */
export function getNearestStore(data, success, fail) {
  return request({
    url: config.api + "/qyxd/xcx/findstore",
    method: "get",
    data,
    success,
    fail,
  });
}

/**
 * 编辑门店信息
 */
export function editStoreInfo(data, success, fail) {
  return request({
    url: config.api + "/xdstore/storeBasics",
    method: "PUT",
    data,
    success,
    fail,
  });
}

/**
 * 保存巡店记录
 */
export function saveXDInfo(data, success, fail) {
  return request({
    url: config.api + "/qyxd/xcx/savestore",
    method: "POST",
    data,
    success,
    fail,
  });
}

/**
 * 查询一级销区列表
 */
export function getRp02nameList(data, success, fail) {
  return request({
    url: config.api + "/qyxd/xcx/gradeOne",
    method: "get",
    data,
    success,
    fail,
  });
}

/**
 * 查询二级销区列表
 */
export function getRp03nameList(data, success, fail) {
  return request({
    url: config.api + "/qyxd/xcx/gradeTwo",
    method: "get",
    data,
    success,
    fail,
  });
}

/**
 * 查询品牌列表
 */
export function getBrandList(data, success, fail) {
  return request({
    url: config.api + "/qyxd/xcx/brand",
    method: "get",
    data,
    success,
    fail,
  });
}

/**
 * 根据一级销区，二级销区，品牌以及门店名称查询查询门店信息列表（原接口：/qyxd/xcx/findStoreName）
 */
export function getStoreList(data, success, fail) {
  return request({
    url: config.api + "/qyxd/xcx/storeList",
    method: "get",
    data,
    success,
    fail,
  });
}

/**
 * 查询导购信息
 */
export function MemberInfoByMemCode(data, success, fail) {
  console.log(config.crmApiUrl);
  return request({
    url: config.crmApiUrl + "MemberInfoByMemCode",
    method: "post",
    data,
    success,
    fail,
  });
}

/**
 * 查询年份季度
 */
export function xcxYear(data, success, fail) {
  return request({
    url: config.api + "/qyxd/xcx/year",
    method: "get",
    data,
    success,
    fail,
  });
}

/**
 * 查询登录用户所属门店是否评价
 */
export function xcxIsEvaluation(data, success, fail) {
  return request({
    url: config.api + "/qyxd/xcx/isEvaluation",
    method: "get",
    data,
    success,
    fail,
  });
}

/**
 * 查询门店评价项目列表
 */
export function xcxProjectList(data, success, fail) {
  return request({
    url: config.api + "/qyxd/xcx/projectList",
    method: "get",
    data,
    success,
    fail,
  });
}

/**
 * 加盟商门店评价保存
 */
export function xcxSaveStoreSurvey(data, success, fail) {
  return request({
    url: config.api + "/qyxd/xcx/saveStoreSurvey",
    method: "post",
    data,
    success,
    fail,
  });
}

/**
 * 阵地维护列表查询
 */
export function getPositionsList(data, success, fail) {
  return request({
    url: config.biApiUrl + "/ords/bidwdb/pw/positionrs",
    method: "get",
    data,
    success,
    fail,
  });
}

/**
 * 阵地信息查询
 */
export function getPositionsInfo(data, success, fail) {
  return request({
    url: config.biApiUrl + "/ords/bidwdb/pw/pwinfo",
    method: "get",
    data,
    success,
    fail,
  });
}

/**
 * 打击目标阵地列表查询
 */
export function getCompetitorList(data, success, fail) {
  return request({
    url: config.biApiUrl + "/ords/bidwdb/pw/competitor",
    method: "get",
    data,
    success,
    fail,
  });
}

/**
 * 阵地信息修订
 */
export function savePositionsInfo(data, success, fail) {
  return request({
    url: config.biApiUrl + "/ords/bidwdb/pw/pwinfo",
    method: "post",
    data,
    success,
    fail,
  });
}

/**
 * 获取部门
 */
export function listByDeptid(data, success, fail) {
  return request({
    url: config.api + "/system/user/listByDeptid",
    method: "get",
    data,
    success,
    fail,
  });
}

/**
 * 获取员工
 */
export function getDeptsByParentId(data, success, fail) {
  return request({
    url: config.api + "/system/dept/alllist",
    method: "get",
    data,
    success,
    fail,
  });
}

/**
 * 获取我配置的权限
 */
export function getMyPowerConfig(data, success, fail) {
  return request({
    url: config.api + "/powerDept/powerDept/myPowerConfig",
    method: "get",
    data,
    success,
    fail,
  });
}

/**
 * 点击某人获取他的权限范围
 */
export function findPowerBycode(data, success, fail) {
  return request({
    url: config.api + "/powerDept/powerDept/findPowerBycode",
    method: "get",
    data,
    success,
    fail,
  });
}

/**
 * 删除权限
 */
export function delectPower(data, success, fail) {
  return request({
    url: config.api + "/powerDept/powerDept/delectPower",
    method: "get",
    data,
    success,
    fail,
  });
}

/**
 * 查看我的权限
 */
export function findMyPower(data, success, fail) {
  return request({
    url: config.api + "/powerDept/powerDept/findMyPower",
    method: "get",
    data,
    success,
    fail,
  });
}

/**
 * 可选的顶层权限
 */
export function getAddPower(data, success, fail) {
  return request({
    url: config.api + "/powerDept/powerDept/addPower",
    method: "get",
    data,
    success,
    fail,
  });
}

/**
 * 保存权限范围
 */
export function savePower(data, success, fail) {
  return request({
    url: config.api + "/powerDept/powerDept/savePower",
    method: "post",
    data,
    success,
    fail,
  });
}

/**
 * 我管理的
 */
export function getMyManagerPower(data, success, fail) {
  return request({
    url: config.api + "/powerDept/powerDept/myManagePower",
    method: "get",
    data,
    success,
    fail,
  });
}

/**
 * 删除所有我管理的权限
 */
export function delectAllPower(data, success, fail) {
  return request({
    url: config.api + "/powerDept/powerDept/delectAllPower",
    method: "get",
    data,
    success,
    fail,
  });
}

/**
 * 更新单个员工的权限
 */
export function savePowerSource(data, success, fail) {
  return request({
    url: config.api + "/powerDept/powerDept/savePowerSource",
    method: "get",
    data,
    success,
    fail,
  });
}

/**
 * 查询会议主题列表（分页）
 */
export function getVoteThemeAllList(data, success, fail) {
  return request({
    url: config.api + "/vote/theme/uniappList",
    method: "get",
    data,
    success,
    fail,
  });
}

/**
 * 查询投票项列表
 */
export function getVoteItemsList(data, success, fail) {
  return request({
    url: config.api + "/vote/item/uniappList",
    method: "get",
    data,
    success,
    fail,
  });
}

/**
 * 投票 / 选举
 */
export function addVoteLog(data, success, fail) {
  return request({
    url: config.api + "/vote/log",
    method: "post",
    data,
    success,
    fail,
  });
}

/**
 * 查询投票结果
 * 参数：id
 */
export function getVoteResult(id, success, fail) {
  return request({
    url: config.api + "/vote/log/" + id,
    method: "get",
    data: {},
    success,
    fail,
  });
}

// 删除 start
/**
 * 助店任务记录
 */
export function getTaskAllList(data, success, fail) {
  return request({
    url: config.api + "/zdqd/task/allList",
    method: "post",
    data,
    success,
    fail,
  });
}

/**
 * 获取助店任务记录详情详细信息
 */
export function getTaskDetail(data, success, fail) {
  return request({
    url: config.api + `/zdqd/task_detail/${data}`,
    method: "get",
    data,
    success,
    fail,
  });
}

/**
 * 助店任务配置列表
 */
export function queryTaskConfigList(data, success, fail) {
  return request({
    url: config.api + "/zdqd/task_config/allList",
    method: "get",
    data,
    success,
    fail,
  });
}

/**
 * 助店详情新增
 */
export function addTaskDetail(data, success, fail) {
  return request({
    url: config.api + "/zdqd/task_detail/add-task-detail",
    method: "post",
    data,
    success,
    fail,
  });
}

/**
 * 根据门店id查询助店任务列表
 */
 
export function queryByStoreId(data, success, fail) {
  return request({
    url: config.api + `/zdqd/task_config/byStoreId?storeId=${data}`,
    method: "get",
    success,
    fail,
  });
}

/**
 * 店铺类型查询
 */
 
export function getStoreType(data, success, fail) {
  return request({
    url: config.api + `/zdqd/task/storeType?storeId=${data}`,
    method: "get",
    success,
    fail,
  });
}
// 删除 end

/**
 * 获取助店任务表单
 */

export function getCreateTaskForm(data, success, fail) {
  return request({
    url: config.api + "/xdstore/task/ext/create/form",
    method: "get",
    data,
    success,
    fail,
  });
}

/**
 * 获取助店任务保存
 */

export function saveTaskExt(data, success, fail) {
  return request({
    url: config.api + "/xdstore/task/ext/save",
    method: "post",
    data,
    success,
    fail,
  });
}

/**
 * 助店任务配置列表
 */
export function getTaskConfigList(data, success, fail) {
  return request({
    url: config.api + "/xdstore/task/ext/config/list",
    method: "get",
    data,
    success,
    fail,
  });
}

/**
 * 品牌列表
 */
export function getTaskBrand(data, success, fail) {
  return request({
    url: config.api + "/xdstore/task/ext/brands",
    method: "get",
    data,
    success,
    fail,
  });
}

/**
 * 
助店任务品牌列表
 */
export function getTaskConfigBrand(data, success, fail) {
  return request({
    url: config.api + "/xdstore/task/ext/config/brands",
    method: "get",
    data,
    success,
    fail,
  });
}


/**
 * 修改/新增助店任务 助店任务配置列表
 */
export function editTaskConfig(data, success, fail) {
  return request({
    url: config.api + "/xdstore/task/ext/config/save",
    method: "post",
    data,
    success,
    fail,
  });
}

/**
 * 删除助店任务 助店任务配置列表
 */
export function deleteTaskConfig(data, success, fail) {
  return request({
    url: config.api + '/xdstore/task/ext/config/delete',
    method: "post",
    data,
    success,
    fail,
  });
}

/**
 * 助店打卡记录列表 
**/
export function getTaskExtConfigList(data, success, fail) {
  return request({
    url: config.api + "/xdstore/task/ext/list",
    method: "get",
    data,
    success,
    fail,
  });
}

/**
 * 助店打卡详情
**/
export function getTaskExtDetaul(data, success, fail) {
  return request({
    url: config.api + "/xdstore/task/ext/detail",
    method: "get",
    data,
    success,
    fail,
  });
}

/**
 * 经纬度换取地点信息
**/
export function wxGetTxMapByLatLng(data, success, fail) {
  return request({
    url: config.crmApiUrl + "wxGetTxMapByLatLng",
    method: "post",
    data,
    success,
    fail,
  });
}

/**
 * 获取店面类型
**/
export function getStoreTypes(data, success, fail) {
  return request({
    url: config.api + "/xdstore/storeBasics/storeTypes",
    method: "get",
    data,
    success,
    fail,
  });
}

/**
 * 助店打卡待办列表
**/
export function getTaskExtTodoList(data, success, fail) {
  return request({
    url: config.api + "/xdstore/task/todo/list",
    method: "get",
    data,
    success,
    fail,
  });
}

/**
 * 助店打卡待办数量
**/
export function getTaskExtTodoCount(data, success, fail) {
  return request({
    url: config.api + "/xdstore/task/todo/getCount",
    method: "get",
    data,
    success,
    fail,
  });
}

/**
 * 助店打卡待办详情
**/
export function getTaskExtTodoDetail(data, success, fail) {
  return request({
    url: config.api + "/xdstore/task/todo/detail",
    method: "get",
    data,
    success,
    fail,
  });
}

/**
 * 助店打卡待办标记完成
**/
export function flagTaskExtTodoItem(data, success, fail) {
  return request({
    url: config.api + "/xdstore/task/todo/addResult",
    method: "post",
    data,
    success,
    fail,
  });
}

/**
 * 查询办公室地址管理列表
**/
export function dofficeList(data, success, fail) {
  return request({
    url: config.api + "/officeArea/basics/allList",
    method: "get",
    data,
    success,
    fail,
  });
}

/**
 * 查询仓库地址管理列表
**/
export function storeHouseList(data, success, fail) {
  return request({
    url: config.api + "/storeHouse/basics/allList",
    method: "get",
    data,
    success,
    fail,
  });
}

// 销区
export function regionList(data, success, fail) {
  return request({
    url: config.api + "/officeArea/basics/region",
    method: "get",
    data,
    success,
    fail,
  });
}

// 省市

export function provinceList(data, success, fail) {
  return request({
    url: config.api + "/storeHouse/basics/getProvince",
    method: "get",
    data,
    success,
    fail,
  });
}

/**
 * 网点招商列表列表
**/
export function getBranchInverstList(data, success, fail) {
  return request({
    url: config.api + "/xdstore/blankFranchise/list2",
    method: "get",
    data,
    success,
    fail,
  });
}

/**
 * 网点招商各状态数量
**/
export function getBranchInverstListCount(data, success, fail) {
  return request({
    url: config.api + "/xdstore/blankFranchise/getCount",
    method: "get",
    data,
    success,
    fail,
  });
}
/**
 * 新建网点招商
**/
export function createBranchInvestOrder(data, success, fail) {
  return request({
    url: config.api + "/xdstore/blankFranchise",
    method: "post",
    data,
    success,
    fail,
  });
}
/**
 * 修改网点招商
**/
export function editBranchInvestOrder(data, success, fail) {
  return request({
    url: config.api + "/xdstore/blankFranchise",
    method: "put",
    data,
    success,
    fail,
  });
}
/**
 * 网点招商详情
**/
export function getBranchInvestOrderDetail(id, success, fail) {
  if (!id) {
    throw new Error("请传入id");
  }
  return request({
    url: config.api + "/xdstore/blankFranchise/" + id,
    method: "get",
    success,
    fail,
  });
}
/**
 * 启动网点招商
**/
export function startBranchInvestOrder(data, success, fail) {
  return request({
    url: config.api + "/xdstore/blankFranchise/start",
    method: "put",
    data,
    success,
    fail,
  });
}

/**
 * 网点招商逾期时间变更
**/
export function changeBranchInvestOrderOvertime(data, success, fail) {
  return request({
    url: config.api + "/xdstore/blankFranchise/overdue",
    method: "put",
    data,
    success,
    fail,
  });
}

/**
 * 网点招商逾期关闭
**/
export function closeBranchInvestOrder(data, success, fail) {
  return request({
    url: config.api + "/xdstore/blankFranchise/close",
    method: "put",
    data,
    success,
    fail,
  });
}

/**
 * 网点招商完成
**/
export function completeBranchInvestOrder(data, success, fail) {
  return request({
    url: config.api + "/xdstore/blankFranchise/complete",
    method: "put",
    data,
    success,
    fail,
  });
}

/**
 * 查询地理位置信息
 */
export function getAllRegionByParentId(id, success, fail) {
  return request({
    url: config.api + "/region/region/allList?parentId=" + id,
    method: "get",
    success,
    fail,
  });
}


/**
 * 网点备案列表
 */
export function getDotList(data, success, fail) {
  return request({
    url: config.api + "/outlets/customer/list2",
    method: "get",
	data,
    success,
    fail,
  });
}

/**
 * 网点备案列表状态数量
 */
export function getDotNumList(data, success, fail) {
  return request({
    url: config.api + "/outlets/customer/getCount",
    method: "get",
	data,
    success,
    fail,
  });
}


/**
 * 新增网点备案
 */
export function addDot(data, success, fail) {
  return request({
    url: config.api + "/outlets/customer/save",
    method: "post",
	data,
    success,
    fail,
  });
}

/**
 * 修改网点备案
 */
export function editDot(data, success, fail) {
  return request({
    url: config.api + "/outlets/customer",
    method: "put",
	data,
    success,
    fail,
  });
}


/**
 * 关闭网点备案
 */
export function closeDot(data, success, fail) {
  return request({
    url: config.api + "/outlets/customer/close",
    method: "put",
	data,
    success,
    fail,
  });
}

/**
 * 依据关键字搜索选商名称
 */
export function queryKeyXdstore(data, success, fail) {
  return request({
    url: config.api + "/xdstore/blankFranchise/queryKeyList",
    method: "get",
	data,
    success,
    fail,
  });
}


/**
 * 搜索网点选商备案列表(H5新增)
 */
export function queryKeyOutlets(data, success, fail) {
  return request({
    url: config.api + "/outlets/customer/queryKeyList",
    method: "get",
	data,
    success,
    fail,
  });
}



/**
 * 查询网点选商日志跟进列表(H5)
 */
export function followupList(data, success, fail) {
  return request({
    url: config.api + "/outlets/followup/list2",
    method: "get",
	data,
    success,
    fail,
  });
}



/**
 * 依据条件查询网点选商日志跟进状态数量(H5)
 */
export function followupCount(data, success, fail) {
  return request({
    url: config.api + "/outlets/followup/getCount",
    method: "get",
	data,
    success,
    fail,
  });
}

/**
 * 新增网点选商日志跟进
 */
export function followup(data, success, fail) {
  return request({
    url: config.api + "/outlets/followup",
    method: "post",
	data,
    success,
    fail,
  });
}

/**
 * 修改网点选商日志跟进
 */
export function editFollowup(data, success, fail) {
  return request({
    url: config.api + "/outlets/followup",
    method: "put",
	data,
    success,
    fail,
  });
}


/**
 * 获取网点选商日志跟进详细信息
 */
export function followupDetail(data,success, fail) {
  return request({
    url: config.api + "/outlets/followup/"+data,
    method: "get",
	data,
    success,
    fail,
  });
}


/**
 * 获取网点选商日志跟进详细信息
 */
export function followupApprove(data,success, fail) {
  return request({
    url: config.api + "/outlets/approve",
    method: "post",
	data,
    success,
    fail,
  });
}

/**
 * 获取网点选商日志跟进详细信息
 */
export function getLogByMerchantCode(data,success, fail) {
  return request({
    url: config.api + "/outlets/followup/getLogByMerchantCode",
    method: "get",
	data,
    success,
    fail,
  });
}















